<?php

session_start();

include "connect.php";

// 1. Gets the customers email address
// 2. Checks if email address is already in the unregistered email address table
// 3. Adds the email address to the table

$customer_email = $_GET['email'];

$today = date("Y,m,d");

$query = "SELECT * FROM unregistered_emails WHERE email_address = '$customer_email'";
$result = mysql_query($query);
$count = mysql_num_rows($result);

if($count != 1)

	{
	mysql_query("INSERT INTO unregistered_emails 

	(
	
	email_address,
	date_unregistered
		
	) 
	
	VALUES
	
	(
	
	'$customer_email',
	'$today')
	
	 "); 
	} 
	
/////
//End
/////

header('Location: index.php?');

//////////
//Testing
//////////

$query = "SELECT * FROM unregistered_emails";
$result = mysql_query($query);
	
while($row = mysql_fetch_array($result))

	{
	//echo $row['email_address']."</br>";
	}

//echo $count."<br />";	
//echo $customer_email;

?>